<?php

namespace app\index\controller;

use app\common\YujisoController;
use app\index\service\ShipService;

class Ship extends YujisoController
{
    public function __construct(){
        parent::__construct();
    }
    public function index(){
        exitJson(ShipService::getList($this->param));
    }
    //详情 创建 修改
    public function create(){
        $param=$this->request->post();
        if ($this->request->isPost()) {
            $list=json_decode($param['list'],true);
            unset($param['list']);
            $param['list']=$list;
            if($this->param['id']){
                //编辑
                $res=ShipService::create($param);
            }else{
                //新建
                $res=ShipService::create($param);
            }
            exitJson($res);
        } else {
            //详情
            exitJson(ShipService::detail($this->param));
        }
    }
    //编辑页面返回明细
    public function detail(){
        returnJson(1,'',[],0);
    }
    //编辑页面返回明细
    public function logistics(){
        exitJson(ShipService::logistics($this->param));
    }
    //上传明细
    public function upload(){
        $param=[];
        $param['title']=['店铺','sku','理论需求量','实际计划发货量','单位体积'];//必须校验头部
        $param['actionAsync']='\app\index\service\ShipService::uploadHandle';//上传数据的数据回调到service层处理
        $res=\app\common\service\ExcelLibraryService::read($param);
        exitJson($res);
    }
    //上传明细标记
    public function uploadSign(){
        $param=[];
        $param['list']=$this->request->post('list');
        $param['title']=['店铺','sku','实际计划发货量'];//必须校验头部
        $param['actionAsync']='\app\index\service\ShipService::uploadSignHandle';//上传数据的数据回调到service层处理
        $res=\app\common\service\ExcelLibraryService::read($param);
        exitJson($res);
    }
    public function getCompanyType(){
        exitJson(ShipService::getCompanyType($this->param));
    }
}